
#ifndef __POLYV2_H__
#define	__POLYV2_H__

#include "Vertex4d.h"
#include "GameBitMap.h"

// new
#define POLY4DV2_ATTR_ENABLE_MATERIAL       0x0800 // use a real material for lighting
#define POLY4DV2_ATTR_DISABLE_MATERIAL      0x1000 // use basic color only for lighting (emulate version 1.0)

//2.0 type

// a self contained polygon used for the render list version 2 /////////////////////////
typedef struct POLYF4DV2_TYP
{
	int      state;           // state information
	int      attr;            // physical attributes of polygon
	int      color;           // color of polygon
	int      lit_color[3];    // holds colors after lighting, 0 for flat shading
	// 0,1,2 for vertex colors after vertex lighting
	CBitMapImage* texture; // pointer to the texture information for simple texture mapping

	int      mati;    // material index (-1) for no material  (new)

	float    nlength; // length of the polygon normal if not normalized (new)
	CVector4d normal;  // the general polygon normal (new)

	float    avg_z;   // average z of vertices, used for simple sorting (new)

	CVertex4d vlist[3];  // the vertices of this triangle 
	CVertex4d tvlist[3]; // the vertices after transformation if needed 

	POLYF4DV2_TYP *next;   // pointer to next polygon in list??
	POLYF4DV2_TYP *prev;   // pointer to previous polygon in list??

} POLYF4DV2, *POLYF4DV2_PTR;

// a polygon ver 2.0 based on an external vertex list  //////////////////////////////////
typedef struct POLY4DV2_TYP
{
	int state;           // state information
	int attr;            // physical attributes of polygon
	int color;           // color of polygon
	int lit_color[3];    // holds colors after lighting, 0 for flat shading
	// 0,1,2 for vertex colors after vertex lighting

	CBitMapImage* texture; // pointer to the texture information for simple texture mapping

	int mati;              // material index (-1) no material (new)

	CVertex4d*		vlist; // the vertex list itself 
	CPoint2d*		tlist; // the texture list itself (new)
	int vert[3];           // the indices into the vertex list
	int text[3];           // the indices into the texture coordinate list (new)
	float nlength;         // length of normal (new)

} POLY4DV2, *POLY4DV2_PTR;

#endif